﻿<%@ Page Language="C#" AutoEventWireup="true"  %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title></title>
    <script charset="utf-8" type="text/javascript"  src="../../../Page/Common/head.js"></script>
</head>
<body>
    <div name="department-panel" class="mini-panel" title="选择部门" bodyStyle="padding:0;" showToolbar="true" showHeader="false" showFooter="false" style="width:100%;height:100%;" borderStyle="border:0;" >
	    <div property="toolbar" style="padding:2px;">       
	        <a name="btn_deptDepartment" class="mini-button" iconCls="icon-zoom" plain="true" >部门</a>
	        <span class="separator"></span>
	        <a name="btn_customerDepartment" class="mini-button" iconCls="icon-zoom" plain="true" >客户</a>
	        <span class="separator"></span>
	        <a name="btn_joinedProductionsupplierDepartment" class="mini-button" iconCls="icon-zoom" plain="true" >外协</a>
	        <span class="separator"></span>
	        <a name="btn_ComponentSubcontractorDepartment" class="mini-button" iconCls="icon-zoom" plain="true" >二配</a>
	        <span class="separator"></span>
	        <a name="btn_purchasesupplierDepartment" class="mini-button" iconCls="icon-zoom" plain="true" >采购</a>
	    </div>
	    <ul name="department-tree" class="mini-tree" style="width:100%;padding:5px;" expandOnLoad="false"
	        showTreeIcon="true" textField="Name" idField="Id" parentField="ParentId" resultAsTree="false"  
	        >
	    </ul>
	     <div property="footer" >
			<table style="width:100%;">
				<tr>					
					<td style="text-align:right">
				        <a class="mini-button" name="departmentTree_cancelBtn" style=" width:70px;margin-right:10px">关 闭</a>
					</td>
				</tr>
			</table>
	    </div> 
	</div>	
    <script type="text/javascript">
		mini.parse();		
		//加载数据
		var tree=mini.getbyName("department-tree");		

		//部门按钮
        var deptBtn = mini.getbyName("btn_deptDepartment");
        deptBtn.on('click',function(){
            loadByType("dept","department");
        },this);
        //客户按钮
        var custBtn = mini.getbyName("btn_customerDepartment");
        custBtn.on('click',function(){
            loadByType("cust","customer");
        },this);
        //外协按钮
        var purchaseBtn = mini.getbyName("btn_joinedProductionsupplierDepartment");
        purchaseBtn.on('click',function(){
            loadByType("purchaseSuply","purchasesupplier");
        },this);
        //二配按钮
        var CompBtn = mini.getbyName("btn_ComponentSubcontractorDepartment");
        CompBtn.on('click',function(){
            loadByType("ComponentSubcontractorSuply","ComponentSubcontractor");
        },this);
        //采购按钮
        var joinedBtn = mini.getbyName("btn_purchasesupplierDepartment");
        joinedBtn.on('click',function(){
            loadByType("joinedProductionSuply","joinedProductionsupplier");
        },this);

        //展开节点前发生
        tree.on('beforeload', function (e) {
            var level="root";
            var params = e.params;  //参数对象
            if(!mini.isEmpty(e.node) && !mini.isEmpty(e.node.id)){
                level=e.node.id;
            }
            //可以传递自定义的属性
            params.node = level; //后台：request对象获取"node"
        }, this);

        //根据部门类别加载部门数据 
	    function loadByType(type){
	        if(!mini.isEmpty(type)){
        		var storeUrl = bootPATH+GNC.Uri.GetOrganizationsTree.replace('js=1','js=2');
	            tree.setUrl(storeUrl+'&type='+type);
	        }
	    }

	    tree.on('nodeclick',function(rec){
	        var data={};
            data={
                action:'ok',
                id:rec.node.id,
                Name:rec.node.Name
            }
	        /*data.push('ok');
	        data.push(rec.node.id);
	        data.push(rec.node.Name);*/
	        return window.CloseOwnerWindow(data);
	    });


		///////////////////////////////////////////////
        //保存按钮
        /*var saveBtn = mini.getbyName('departmentTree_saveBtn');
       	//------按钮点击事件 ----------------------
       	//保存
        saveBtn.on('click',function(){        	
        	var row = tree.getSelectedNode();
        	if(mini.isEmpty(row.id)){
        		mini.alert('请选择部门!','警告');
        		return;
	        }
        	onFormAction("ok")
        });*/
        //取消
        var cancelBtn = mini.getbyName('departmentTree_cancelBtn');
        cancelBtn.on('click',function(){
        	onFormReset();
        });
		
	    ///////////////////////////////////////////////
	    //接受的数据
        /*function setData(Id,Name) {
        	if(!mini.isEmpty(Id)){

        	}
        }
	    //返回的数据
        function getData() {        	
        	var row = tree.getSelectedNode();
        	return row;			
		}	*/	
    </script>
</body>
</html>
